package com.hrbxlh.actionImpl;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.hrbxlh.dao.LoginDao;
import com.hrbxlh.util.PubMethods;


@Component("loginActionImpl")
@Transactional
public class LoginActionImpl {
	
	@Resource(name = "loginDao")
	private LoginDao loginDao;
	
	/**
	 * @description 更改登陆退出时间
	 *
	 */
	public boolean upLogin(HttpSession session) throws Exception {

		boolean flag = false;
		Map<String, Object> paramMap = new HashMap<String,Object>();
		try {
			
			String loginoutTime = PubMethods.getNowTime(new Date());
			paramMap.put("loginoutTime", loginoutTime);
			paramMap.put("mainId", session.getAttribute("mainId"));
			flag = loginDao.upLogin(paramMap);
			if(flag){
				//清空session
				session.removeAttribute("stuorteaId");
				session.removeAttribute("roleId");
				session.removeAttribute("userName");
				session.removeAttribute("mainId");
			}
		} catch (Exception e) {
			throw e;
		}
		return flag;
	}

}
